package com.transino.bop.domain;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

import com.kanas.framework.support.AbstractModel;

@XmlRootElement(name = "category")
public class PropertyGroup extends AbstractModel implements Cloneable,Comparable<PropertyGroup> {

	private static final long serialVersionUID = 1L;
	
	private String id;
	private String name;
	private String defaultShow;
	private Integer index;
	private List<Property> properties;
	private Entity entity;
	
	@XmlAttribute(name = "id")
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}
	
	@XmlAttribute(name = "name")
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@XmlAttribute(name = "index")
	public Integer getIndex() {
		return index;
	}
	
	public void setIndex(Integer index) {
		this.index = index;
	}

	@XmlAttribute(name = "defaultShow")
	public String getDefaultShow() {
		return defaultShow;
	}

	public void setDefaultShow(String defaultShow) {
		this.defaultShow = defaultShow;
	}

	public List<Property> getProperties() {
		if(properties == null) properties = new ArrayList<Property>();
		return properties;
	}

	public void setProperties(List<Property> properties) {
		this.properties = properties;
	}
	
	@Override
	public int compareTo(PropertyGroup o) {
		if(this.index==null || o.getIndex()==null) {
			return 1;
		}else {
			return this.index - o.getIndex();
		}
	}

	@Override
	public String toIdString() {
		return this.id;
	}

	public Entity getEntity() {
		return entity;
	}

	public void setEntity(Entity entity) {
		this.entity = entity;
	}
	
}
